package me.landery.modules.sinco.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.landery.base.BaseEntity;
import me.landery.modules.system.domain.User;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
 * @website https://el-admin.vip
 * @description /
 * @author landery
 * @date 2022-06-22
 **/
@Entity
@Data
@Table(name="sinco_recommend")
public class Recommend extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

//    @Column(name = "uid",nullable = false)
    @NotNull
    @ApiModelProperty(value = "用户id")
    @OneToOne
    @JoinColumn(name = "uid")
    private User user;

    @Column(name = "refer_code")
    @ApiModelProperty(value = "推荐码")
    private String referCode;

    public void copy(Recommend source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}